/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author damfercer
 */
@Entity
@Table(name = "candidate_interest_area")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CandidateInterestArea.findAll", query = "SELECT c FROM CandidateInterestArea c"),
    @NamedQuery(name = "CandidateInterestArea.findByIdCandidateInterestArea", query = "SELECT c FROM CandidateInterestArea c WHERE c.idCandidateInterestArea = :idCandidateInterestArea")})
public class CandidateInterestArea implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_CANDIDATE_INTEREST_AREA")
    private Integer idCandidateInterestArea;
    @JoinColumn(name = "DESIRED_SALARY", referencedColumnName = "ID_DESIRED_SALARY")
    @ManyToOne(fetch = FetchType.LAZY)
    private DesiredSalary desiredSalary;
    @JoinColumn(name = "JOB_POSITION", referencedColumnName = "ID_JOB_POSITION")
    @ManyToOne(fetch = FetchType.LAZY)
    private JobPosition jobPosition;
    @JoinColumn(name = "SECTOR", referencedColumnName = "ID_SECTOR")
    @ManyToOne(fetch = FetchType.LAZY)
    private Sector sector;
    @JoinColumn(name = "CANDIDATE", referencedColumnName = "ID_CANDIDATE")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Candidate candidate;

    public CandidateInterestArea() {
    }

    public CandidateInterestArea(Integer idCandidateInterestArea) {
        this.idCandidateInterestArea = idCandidateInterestArea;
    }

    public Integer getIdCandidateInterestArea() {
        return idCandidateInterestArea;
    }

    public void setIdCandidateInterestArea(Integer idCandidateInterestArea) {
        this.idCandidateInterestArea = idCandidateInterestArea;
    }

    public DesiredSalary getDesiredSalary() {
        return desiredSalary;
    }

    public void setDesiredSalary(DesiredSalary desiredSalary) {
        this.desiredSalary = desiredSalary;
    }

    public JobPosition getJobPosition() {
        return jobPosition;
    }

    public void setJobPosition(JobPosition jobPosition) {
        this.jobPosition = jobPosition;
    }

    public Sector getSector() {
        return sector;
    }

    public void setSector(Sector sector) {
        this.sector = sector;
    }

    public Candidate getCandidate() {
        return candidate;
    }

    public void setCandidate(Candidate candidate) {
        this.candidate = candidate;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCandidateInterestArea != null ? idCandidateInterestArea.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        boolean res=false;
        if (object instanceof CandidateInterestArea) {
            CandidateInterestArea other=(CandidateInterestArea)object;
            if(this.getIdCandidateInterestArea()!=null && other.getIdCandidateInterestArea()!=null){
                res=this.getIdCandidateInterestArea().equals(other.getIdCandidateInterestArea());
            }
            else{
                if(this.getSector() !=null && other.getSector()!=null){
                    if(this.getJobPosition()!=null && other.getJobPosition()!=null){
                        res=this.getJobPosition().getIdJobPosition().equals(other.getJobPosition().getIdJobPosition()) && this.getSector().getIdSector().equals(other.getSector().getIdSector());
                    }
                    else{
                        res=this.getSector().getIdSector().equals(other.getSector().getIdSector());
                    }
                }
                else if(this.getJobPosition()!=null && other.getJobPosition()!=null){
                    if(this.getDesiredSalary()!=null && other.getDesiredSalary()!=null){
                        res=this.getDesiredSalary().equals(other.getDesiredSalary()) && this.getJobPosition().getIdJobPosition().equals(other.getJobPosition().getIdJobPosition());
                    }
                    else{
                        res=this.getJobPosition().getIdJobPosition().equals(other.getJobPosition().getIdJobPosition());
                    }
                }
                else if(this.getDesiredSalary()!=null && other.getDesiredSalary()!=null){
                    res=this.getDesiredSalary().equals(other.getDesiredSalary());
                }
            }
        }
        return res;
    }

    @Override
    public String toString() {
        return "entities.CandidateInterestArea[ idCandidateInterestArea=" + idCandidateInterestArea + " ]";
    }
    
}
